package com.cg.advice;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.HashMap;
import java.util.Map;

@RestControllerAdvice
public class GlobalExceptionAdvice {

    @ExceptionHandler(RuntimeException.class)
    public Map<Object, Object> runtimeException(Exception e) {
        Map<Object, Object> map = new HashMap<>();
        map.put("code", 500);
        map.put("msg", "业务异常" + e.getMessage());
        return map;
    }

}
